import 'package:base_plugin/base_plugin.dart';
import 'package:dio/dio.dart';

/// 获取库存历史
class HttpInventoryService {
  /// 获取库存历史
  static Future<Response> getInventoryList(int productId) {
    return BaseConfig.httpBase.get('/api/inventories', {
      'product_id': productId,
    });
  }

  static Future<Response> getInventoryBatchList(int productId, String batch) {
    return BaseConfig.httpBase.get('/api/inventories', {
      'product_id': productId,
      'batch': batch,
    });
  }

  static Future<Response> showInventory(int id) {
    return BaseConfig.httpBase.get('/api/inventories/$id', {});
  }

  /// 获取库存历史
  static Future<Response> updateInventory(
    int productId, {
    String type,
    int quantity,
    String issued_at,
    List attachment_ids,
  }) {
    return BaseConfig.httpBase.postJson('/api/inventories', {
      'product_id': productId,
      'type': type,
      'quantity': quantity,
      'issued_at': issued_at,
      'attachment_ids': attachment_ids ?? [],
    });
  }
}
